package com.hemerasolutions.v2trainer.model.exercise.intensity;


import com.hemerasolutions.v2trainer.model.base.BaseModel;
import com.hemerasolutions.v2trainer.model.exercise.PhysicalCapacity;
import com.hemerasolutions.v2trainer.model.unit.intensity.Rpe;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;


@Entity
public class IntensityModZone extends BaseModel {
 
	private static final long serialVersionUID = 1L;
	
    @Column( length = 2 )
	private int position;
	 
    @Column( length = 30 )
	private String name;
    
    @Column( length = 30 )
	private String alias;

    @ManyToOne
    private Rpe lowRpe;

    @ManyToOne
    private Rpe highRpe;
    
    @Column( length = 7 )
	private String color;
	
	@ManyToOne
	private PhysicalCapacity physicalCapacity;

	@ManyToOne
	private IntensityModTable intensityModTable;
	
	public IntensityModZone() {
		super();
	}
	
	public IntensityModZone(IntensityModTable intensityModTable) {
		super();
		this.intensityModTable = intensityModTable;
		this.position = intensityModTable.getIntensityModZones().size();
		
	}

	public IntensityModZone(IntensityModZone other,IntensityModTable imt){
		this();
		this.intensityModTable = imt;
		this.alias = other.alias;
		this.color = other.color;
		this.highRpe = other.highRpe;
		this.lowRpe = other.lowRpe;
		this.name = other.name;
		this.physicalCapacity = other.physicalCapacity;
		this.position = other.position;
	}
	
	
	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public int getPosition() {
		return position;
	}

	public String getName() {
		return name;
	}

	public String getColor() {
		return color;
	}


	public void setPosition(int position) {
		this.position = position;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setColor(String color) {
		this.color = color;
	}

	public IntensityModTable getIntensityModTable() {
		return intensityModTable;
	}

	public void setIntensityModTable(IntensityModTable intensityModTable) {
		this.intensityModTable = intensityModTable;
	}

	public PhysicalCapacity getPhysicalCapacity() {
		return physicalCapacity;
	}

	public void setPhysicalCapacity(PhysicalCapacity physicalCapacity) {
		this.physicalCapacity = physicalCapacity;
	}


	public String getAlias() {
		return alias;
	}

	public void setAlias(String alias) {
		this.alias = alias;
	}
	
	public Rpe getHighRpe() {
		return highRpe;
	}

	public void setHighRpe(Rpe highRpe) {
		this.highRpe = highRpe;
	}

	public Rpe getLowRpe() {
		return lowRpe;
	}

	public void setLowRpe(Rpe lowRpe) {
		this.lowRpe = lowRpe;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((alias == null) ? 0 : alias.hashCode());
		result = prime * result + ((color == null) ? 0 : color.hashCode());
		result = prime * result + ((highRpe == null) ? 0 : highRpe.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime
				* result
				+ ((intensityModTable == null) ? 0 : intensityModTable
						.hashCode());
		result = prime * result + ((lowRpe == null) ? 0 : lowRpe.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime
				* result
				+ ((physicalCapacity == null) ? 0 : physicalCapacity.hashCode());
		result = prime * result + position;
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		IntensityModZone other = (IntensityModZone) obj;
		if (alias == null) {
			if (other.alias != null) {
				return false;
			}
		} else if (!alias.equals(other.alias)) {
			return false;
		}
		if (color == null) {
			if (other.color != null) {
				return false;
			}
		} else if (!color.equals(other.color)) {
			return false;
		}
		if (highRpe == null) {
			if (other.highRpe != null) {
				return false;
			}
		} else if (!highRpe.equals(other.highRpe)) {
			return false;
		}
		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		if (intensityModTable == null) {
			if (other.intensityModTable != null) {
				return false;
			}
		} else if (!intensityModTable.equals(other.intensityModTable)) {
			return false;
		}
		if (lowRpe == null) {
			if (other.lowRpe != null) {
				return false;
			}
		} else if (!lowRpe.equals(other.lowRpe)) {
			return false;
		}
		if (name == null) {
			if (other.name != null) {
				return false;
			}
		} else if (!name.equals(other.name)) {
			return false;
		}
		if (physicalCapacity == null) {
			if (other.physicalCapacity != null) {
				return false;
			}
		} else if (!physicalCapacity.equals(other.physicalCapacity)) {
			return false;
		}
		if (position != other.position) {
			return false;
		}
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "IntensityModZone [id=" + id + ", position=" + position
				+ ", name=" + name + ", alias=" + alias + ", lowRpe=" + lowRpe
				+ ", highRpe=" + highRpe + ", color=" + color
				+ ", physicalCapacity=" + physicalCapacity
				+ ", intensityModTable=" + intensityModTable + "]";
	}



	
	 
}
 
